home *** CD-ROM | disk | FTP | other *** search
- Path: ob1.uws.edu.au!news
- From: Russell Sayers <rsayers@st.nepean.uws.edu.au>
- Newsgroups: comp.lang.c
- Subject: Concurrent file access ??
- Date: Thu, 08 Feb 1996 11:26:24 +1100
- Organization: University of Western Sydney
- Message-ID: <31194330.21FF9711@st.nepean.uws.edu.au>
- NNTP-Posting-Host: 137.154.130.88
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (X11; I; Linux 1.3.53 i486)
-
- I'm currently trying to write a CGI trivia program on my UNIX account at
- universty. The program currently consists of a whole load of functions
- that open a file, do what they have to do, then close the file. These
- functions do things like select a random question entry from a data
- file, then display it in HTML format, or read in a "users" score from
- another data file.
-
- I've noticed that when a function is called within a few lines of the
- last call then it gives bad results. I guessed this was some sort of
- latancy in the open file table. So I put a "sleep(1)" after each time a
- file was closed. This was still not enough for some functions. Some
- required a "sleep(3)" or higher to get a correct result. Though they
- all work when given enough time between file opening and closing, this
- is slowing down my program TOO much!
-
- When a C program of mine has a file opened, I've noticed that in another
- shell the file appear tuncated. Is this something that I cannot work
- around?? How come editors like PICO can have the same file open in two
- sessions? I'm guessing than PICO rapidly reads in the data, then closes
- the file. Even if I can over come this latency this program will most
- probably be running concurrently by several users, am I going to have to
- observe "critical sections".
-
- I'd REALLY appreciate the help,
-
- Russ
- (rsayers@st.nepean.uws.edu.au)
-